<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>

</head>

<body>
    <div class="root">
        <form @submit.prevent="demo">
            <label for="demo">账号：</label>
            <input type="text" id="demo" v-model.trim="userInfo.account">
            <br>
            密码： <input type="password" v-model="userInfo.password">
            <br>
            性别:<br>
            男：<input type="radio" name="sex" v-model="userInfo.sex" value="male">
            女：<input type="radio" name="sex" v-model="userInfo.sex" value="femal">
            <br>
            年龄：<input type="number" v-model.number="userInfo.age">
            <br>
            </input>
            爱好:
            学习：<input type="checkbox" v-model="userInfo.hobby" value="学习">
            音乐：<input type="checkbox" v-model="userInfo.hobby" value="音乐">
            打游戏：<input type="checkbox" v-model="userInfo.hobby" value="打游戏">
            <br>
            所属校区：
            <select v-model="userInfo.city">
                <option value="">请选择校区：</option>
                <option value="beijing">北京</option>
                <option value="shanghai">上海</option>
                <option value="guangzhou">广州</option>
                <option value="shenzhen">深圳</option>
            </select>
            <br>

            其他信息：
            <textarea v-model="userInfo.info"></textarea>
            <br>
            <input type="checkbox" v-model="userInfo.agree">阅读并接受<a href="">用户协议</a>
            <br>
            <input type="submit" value="提交">
            </input>
        </form>

    </div>

</body>
<script>
    new Vue({
        el: ".root",
        data: {
            userInfo: {
                account: "",
                password: "",
                age:"",
                sex: "female",
                hobby: [],
                city: "",
                info: "",
                agree: "",
            }
        },
        methods: {
            demo() {
                // alert("hahahaha")
                // console.log();
                console.log(JSON.stringify(this.userInfo));


            }
        },
    })
</script>

</html>